$(document).ready(function(){
	
	$('.data-table').dataTable({
		"aaSorting": [[5, 'desc']],
		"bJQueryUI": true,
		"sPaginationType": "full_numbers",
		"sDom": '<""l>t<"F"fp>',
		"fnDrawCallback": function () {
			jobDetail();
		}
	});
	
	function jobDetail() {
		$(".btn-info").each(function(){
			$(this).click(function() {
				var jobId=$(this).attr("id");
				$("#config-modal").modal({
					show : true,
					keyboard : true
				});
				$.get("jobDetail?jobId="+jobId, function(data) {
					var json = JSON.parse(data);
					$("#jobId_modal").html(json.jobId);
					$("#originFilename_modal").html(json.originFilename);
					$("#taskType_modal").html(json.taskType);
					$("#jobStatus_modal").html(json.jobStatus);
					$("#taskSize_modal").html(json.taskSize);
					$("#jobServerSumbitTime_modal").html(json.jobServerSumbitTime);
					$("#inQuqueTime_modal").html(json.inQuqueTime);
					$("#computeTime_modal").html(json.computeTime);
					$("#completeTime_modal").html(json.completeTime);
					$("#waitDuration_modal").html(json.waitDuration);
					$("#computeDuration_modal").html(json.computeDuration);
				});
			});
		})
	}
	
	$('input[type=checkbox],input[type=radio],input[type=file]').uniform();
	
	$('select').select2();
	
	$("span.icon input:checkbox, th input:checkbox").click(function() {
		var checkedStatus = this.checked;
		var checkbox = $(this).parents('.widget-box').find('tr td:first-child input:checkbox');		
		checkbox.each(function() {
			this.checked = checkedStatus;
			if (checkedStatus == this.checked) {
				$(this).closest('.checker > span').removeClass('checked');
			}
			if (this.checked) {
				$(this).closest('.checker > span').addClass('checked');
			}
		});
	});	
});

